# In this part of the program the spectrum is cut according the central wavelength
# chosen to be observed and an estimation of the free spectral range based on the 
# expected resolution. The theoritical calculations involves the determination of
# the finesse based in the curve of the reflectance as a function of the wavelength.
# Written by Sergio Scarano Jr (scarano@astro.iag.usp.br) jul 2009.

import numpy
import scipy

lambdasup=waveobs.max()
lambdainf=waveobs.min()

# Looking for the wavelengths and fluxs in the observed spectrum inside
# the range above

i=numpy.where((shiftwave >= lambdainf) & (shiftwave <= lambdasup))                 
cutwave=shiftwave[i]
cutflux=calibflux[i]

# Writting the resulting spectrum

table=numpy.zeros((cutwave.size,2))
table[:,0]=cutwave
table[:,1]=cutflux
#namefile=objname+'_Cutspec.dat'
#save(namefile, table, fmt='%.6e', delimiter='    ')

#pylab.plot(cutwave,cutflux)
#pylab.show()

